package com.lhc.service.service.impl;

import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import redis.clients.jedis.JedisPool;

import com.lhc.service.service.BaseCacheService;



@Service
public class RedisCacheServiceImpl implements BaseCacheService {
	
	@Autowired
	private RedisTemplate<String, Object> redisTemplate;
	 
	@Autowired
	private JedisPool jedisPool;
	
	/**
	 * 
	 * @desc 批量删除缓存中key，支持模糊删除（需加*）
	 * @author qiliangxi
	 * @date 2016年9月13日下午2:30:14
	 *
	 * @param key
	 */
	public void batchDelete(String key) {
		try {
			Set<String> set = redisTemplate.keys(key);
			Iterator<String> it = set.iterator();
			while (it.hasNext()) {
				String keyStr = it.next();
				redisTemplate.delete(keyStr);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void set(String key, String value) {
		redisTemplate.opsForValue().set(key, value);
	}

	public String get(String key) {
		return (String)redisTemplate.opsForValue().get(key);
	}

	public void append(String key, String value) {
		// TODO Auto-generated method stub
		
	}

	public void del(String key) {
		// TODO Auto-generated method stub
		
	}

	public void expire(String key, long seconds) {
		// TODO Auto-generated method stub
		
	}

	public Long ttl(String key) {
		// TODO Auto-generated method stub
		return null;
	}

	public <T> long rPush(String key, List<T> list) {
		// TODO Auto-generated method stub
		return 0;
	}

	public <T> T lindex(String key, long index) {
		// TODO Auto-generated method stub
		return null;
	}

	public <T> List<T> lRange(String key, long start, long end) {
		// TODO Auto-generated method stub
		return null;
	}

	public void lTrim(String key, long start, long end) {
		// TODO Auto-generated method stub
		
	}

	public <T> void setList(String key, List<T> list) {
		// TODO Auto-generated method stub
		
	}

	public void setHmap(String key, Map<String, Object> map) {
		// TODO Auto-generated method stub
		
	}

	public Map<String, Object> getHmap(String key) {
		// TODO Auto-generated method stub
		return null;
	}

	public void setHmapNotToken(String key, Map<String, Object> map) {
		// TODO Auto-generated method stub
		
	}

	public Map<String, Object> getHmapNotToken(String key) {
		// TODO Auto-generated method stub
		return null;
	}

	public void setPersist(String key) {
		// TODO Auto-generated method stub
		
	}

	public boolean isExist(String key) {
		// TODO Auto-generated method stub
		return false;
	}

	public long jedisSetNx(String key, String value) {
		// TODO Auto-generated method stub
		return 0;
	}

	public long jedisDel(String key) {
		// TODO Auto-generated method stub
		return 0;
	}

	public void jedisExpire(String key, int seconds) {
		// TODO Auto-generated method stub
		
	}

	public void jedisSet(String key, String value) {
		// TODO Auto-generated method stub
		
	}

	public String jedisGet(String key) {
		// TODO Auto-generated method stub
		return null;
	}

	public Set<String> jedisKeys(String pattern) {
		// TODO Auto-generated method stub
		return null;
	}
	
	

}
